function ProcessButton (e) {
	switch (e[0]) {
		case "new_wnd":
			//window.open(e[1], "vrmlWindow", "");
			main_win=window.open(e[1],'vrmlwindow','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes');
		break;
		case "wd_tree":
			//window.open(e[1], "xmlWindow", "");
			loadXMLFile('root', e[1] +  "&fld=" + fld_visible + "&cop=" + class_operations, 1);
			selectedItem = "";
		break;
		case "add_cl":
			link = "index.php?trg=merger&act=addcl&uid=" + selectedItem + "&sid=" + SessionID + "&al=" + e[1];
			loadXMLFile("r", "index.php?trg=merger&act=freewin&sid=" + SessionID, 1);
			loadXMLFile(selectedItem, link, 0);
			loadXMLFile("r", "index.php?trg=merger&act=comments&afteradd=1&sid=" + SessionID, 1);
		break;
		case "save_ont":
			var cDiv = document.getElementById("ir");
			var dataEl = document.getElementById(e[1]);
			var outstr = "";
			for (j = 0; j < dataEl.value.length; j++) {
				var tmpstr = String.fromCharCode(dataEl.value.charCodeAt(j));
				outstr += "-" + dataEl.value.charCodeAt(j) + ";";
			}
			link = "index.php?trg=merger&act=comments&sid=" + SessionID + "&" + e[1] + "=" + outstr;
			
			cDiv.innerHTML = "&nbsp;" + LoadingText;
			loadXMLFile('r', link, 1);
			loadXMLFile('root', "index.php?trg=merger&act=userlist&sid=" + SessionID, 1);
			loadXMLFile('roo', "index.php?trg=merger&act=drnew&sid=" + SessionID, 1);
		break;
		case "div":
			//link = "index.php?trg=" + Target + "&act=" + act + "&uid=" + selectedItem + "&sid=" + SessionID;
			//alert (e[1]+ " - " + e[2]);
			loadXMLFile(e[1], e[2], 1);
			//window.open(e[2], "xmlWindow", "");
		break
		case "search":
			var cDiv = document.getElementById("iroot");
			var outstr = "";
			var dataEl = document.getElementById("stext");
			var idesc = document.getElementById("idesc").checked;
			for (j = 0; j < dataEl.value.length; j++) {
				var tmpstr = String.fromCharCode(dataEl.value.charCodeAt(j));
				outstr += "-" + dataEl.value.charCodeAt(j) + ";";
			}
			link = "index.php?trg=termsearcher&act=userlist&sid="
			+ SessionID
			+ "&stext=" + outstr + "&idesc=" + idesc;
			cDiv.innerHTML = "&nbsp;" + LoadingText;
			//cDiv.innerHTML = link;
			//window.open(link, "xmlWindow", "");
			loadXMLFile('root', link, 1);
		break;
		case "clsearch":
			var cDiv = document.getElementById("iro");
			var outstr = "";
			var dataEl = document.getElementById("stext");
			for (j = 0; j < dataEl.value.length; j++) {
				var tmpstr = String.fromCharCode(dataEl.value.charCodeAt(j));
				outstr += "-" + dataEl.value.charCodeAt(j) + ";";
			}
			link = "index.php?trg=merger&act=showlist&sid=" + SessionID + "&stext=" + outstr;
			cDiv.innerHTML = "&nbsp;" + LoadingText;
			loadXMLFile('ro', link, 1);
		break;
		case "p_wd_tree":
			link = e[1];
			for (i = 2; i < e.length; i++) {
				var dataEl = document.getElementById(e[i]);
				if (dataEl != null) {
					var outstr = "";
					if (dataEl.checked) {
						outstr += "1";
					}
					link += "&" + e[i] + "=" + outstr;
				}
			}
			loadXMLFile('root', link, 1);
			selectedItem = "";
		break;
		case "updateFL":
			link = "index.php?trg=" + Target + "&act=updateFL&wsid=" + document.getElementById ('wsid').value;
			link += "&sid=" + SessionID
			link += "&sname=" + document.getElementById ('sname').value;
			loadXMLFile('nfo_0', link, 1);
		break;
		case "setFunction":
			link = "index.php?trg=" + Target + "&act=setFunction&wsid=" + document.getElementById ('wsid').value;
			link += "&sid=" + SessionID
			link += "&sname=" + document.getElementById ('sname').value;
			link += "&fname=" + document.getElementById ('fname').value;
			loadXMLFile('nfo_0', link, 1);
		break;
		default :
			link = "index.php?trg=" + Target + "&act=update&uid=" + selectedItem + "&sid=" + SessionID + "&fld=" + fld_visible + "&cop=" + class_operations;
			for (i = 1; i < e.length; i++) {
				var dataEl = document.getElementById(e[i]);
				var outstr = "";
				if (e[i] != "iaid") {
					for (j = 0; j < dataEl.value.length; j++) {
						var tmpstr = String.fromCharCode(dataEl.value.charCodeAt(j));
						outstr += "-" + dataEl.value.charCodeAt(j) + ";";
					}
				} else {
					outstr = dataEl.value;
				}
				link += "&" + e[i] + "=" + outstr;
			}
			if (e[0] == "reload") {
				window.location.href = link;
			} else if (e[0] == "0_wd_tree"){
				loadXMLFile('root', link, 1);
				selectedItem = "";
			} else {
				if (e[0] == "bindAttr" || e[0] == "saveWF" || e[0] == "applyWSS") {
					e[0] = "nfo_0";
				} else {
					var cDiv = document.getElementById("info_" + e[0]);
					cDiv.innerHTML = "&nbsp;" + LoadingText;
					//cDiv.innerHTML = link;
					//window.open(link, "xmlWindow", "");
				}
				//window.open(link, "xmlWindow", "");
				loadXMLFile('nfo_' + e[0], link, 1);
			}
		break;
	}
}

function AddRemoveItem (act) {
	if (selectedItem == null || selectedItem == "") {
		selectedItem = "0";
	}
	if (act == "delete") {
		answer = confirm("You are about to introduce permanent changes. Continue?");
	} else {
		answer = true;
	}
	if (act == "delete" && selectedItem == "0") {
		return;
	}
	if (answer) {
		link = "index.php?trg=" + Target + "&act=" + act + "&uid=" + selectedItem + "&sid=" + SessionID;
		//alert (link);
		//window.open(link, "xmlWindow", "");
		loadXMLFile(selectedItem, link, 0);
	}
}

function SearchItem(search_string) {
	//alert(search_string);
	//var dataEl = document.getElementById("search_string");
	//alert(class_operations);
	link = "index.php?trg=" + Target + "&act=search&uid=" + selectedItem + "&sid=" + SessionID + "&sst=" + search_string + "&fld=" + fld_visible + "&cop=" + class_operations;
	//window.open(link, "xmlWindow", "");
	loadXMLFile(selectedItem, link, 0);
};